﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace ICIA.ARojas.Silverlight.Shell
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            btnAdminCurso.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminCurso_Activate);
            btnAdminEspecialidad.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminEspecialidad_Activate);
            btnAdminGrado.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminGrado_Activate);
            btnAdminPersona.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnAdminPersona_Activate);

            btnUsuario.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnUsuario_Activate);
            btnCargo.Activate += new EventHandler<Divelements.SandRibbon.ActivateEventArgs>(btnCargo_Activate);

            this.Loaded += new RoutedEventHandler(MainPage_Loaded);

        }

        void btnCargo_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Cargo.VwCargo());
            f.Show(container);
        }

        void btnUsuario_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Usuario.VwUsuario());
            f.Show(container);
        }

        Login login = new Login();
        Didsoft.Silverlight.ContentManager.Form flogin;

        void MainPage_Loaded(object sender, RoutedEventArgs e)
        {
            login = new Login();
            flogin = new Didsoft.Silverlight.ContentManager.Form(login);
            
            login.onLogueado += new EventHandler(login_onLogueado);            
            flogin.CanMaximize = false;
            flogin.IsModal = true;
            flogin.CanClose = false;
            flogin.Show();
        }

        void login_onLogueado(object sender, EventArgs e)
        {
            flogin.Close();
        }

        void btnAdminPersona_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Persona.MainPage());
            f.Show(container);
        }

        void btnAdminGrado_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Grado.MainPage());
            f.Show(container);
        }

        void btnAdminEspecialidad_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Silverlight.Curso.MainPage());
            f.Show(container);
        }

        void btnAdminCurso_Activate(object sender, Divelements.SandRibbon.ActivateEventArgs e)
        {
            Didsoft.Silverlight.ContentManager.Form f = new Didsoft.Silverlight.ContentManager.Form(new ICIA.ARojas.Visual.Especialidad.MainPage());
            f.Show(container);
        }
    }
}
